{% extends 'base.html' %}
{% import "bootstrap/wtf.html" as wtf %}

{% block page_content %}

<p>{{ movies|length }} Titles</p>
{% if current_user.is_authenticated %}
<form method="post">
    {{ wtf.quick_form(form) }}
</form>
{% endif %}
<br>
<ul class="movie-list">
    {% for post in posts %}
    <li>{{ post.id }} : {{ post.title }} - {{ post.year }}
        <span class="float-right">
            <small>{{ moment(post.timestamp).fromNow(refresh=True) }}</small>-
            {% if current_user.is_authenticated %}
            <a class="btn" href="{{ url_for('edit', movie_id=post.id) }}">编辑</a>
            <form class="inline-form" method="post" action="{{ url_for('.delete', movie_id=post.id) }}">
                <input class="btn" type="submit" name="delete" value="删除" onclick="return confirm('Are you sure?')">
            </form>
            {% endif %}
            <a class="imdb" href="https://search.douban.com/movie/subject_search?search_text={{ post.title }}" target="_blank" title="Find this movie on DouBan">豆瓣</a>
        </span>
    </li>
    {% endfor %}
</ul>
<br>
    <div style="text-align: center">
        {{ pagination.links }}
    </div>
<p>The local date and time is {{ moment(current_time).format('LLL') }}</p>
<img alt="Walking Totoro" class="totoro" src="{{ url_for('static', filename='images/totoro.gif') }}" title="to~to~ro~">
{% endblock %}

{% block paginate %}
<!-- <h2>满嘴顺口溜,你想考研啊</h2>-->
{% endblock %}